package com.code.test;

import com.alibaba.fastjson.JSON;
import com.code.bean.User;
import com.code.config.AutowiredConfig;
import com.code.config.PropertyValuesConfig;
import com.code.controller.MyController;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author wangjie
 * @version V1.0
 * @date 2020/1/6
 */
public class IOCTest_Autowired {

    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(AutowiredConfig.class);


    @Test
    public void test01(){
        printBeans(applicationContext);
        System.out.println("=============");

        MyController myController = (MyController) applicationContext.getBean("myController");
        myController.print();

    }

    private void printBeans(AnnotationConfigApplicationContext applicationContext){
        String[] definitionNames = applicationContext.getBeanDefinitionNames();
        for (String name : definitionNames) {
            System.out.println(name);
        }
    }
}
